package com.example.spring.rabbitmq.controller;

import com.example.spring.rabbitmq.dto.AfterSaleAccountChangeResultDTO;
import com.example.spring.rabbitmq.message.WorkOrderCreateMessageReq;
import com.example.spring.rabbitmq.producer.RabbitmqProducer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * TODO
 *
 * @Description
 * @Author zhengmw
 * @Data 2024/5/15 20:25
 */
@RestController
@Slf4j
public class TestController {
    @Resource
    private RabbitmqProducer producer;

    @GetMapping("/send")
    public void send() {
        AfterSaleAccountChangeResultDTO resultDTO = AfterSaleAccountChangeResultDTO.builder()
                .changeNo("89789456")
                .receiverSystem("ALL")
                .changeType("2")
                .changeStatus("10")
                .remark("审核不通过")
                .build();
        log.info("消息发送成功============");
        producer.send(resultDTO);

    }

    @GetMapping("/send-work-order")
    public void sendWorkOrder() {
        WorkOrderCreateMessageReq.QueryParam queryParam = WorkOrderCreateMessageReq.QueryParam.builder()
                .numberOfPeriods(12)
                .build();
        WorkOrderCreateMessageReq messageResp = WorkOrderCreateMessageReq.builder()
                .businessId("8354321")
                .param(queryParam)
                .orderNo("GF220704072923000141")
                .source("SETTLEMENT")
                .type(10)
                .build();
        producer.sendWorkOrder(messageResp);
    }
}
